package repository

import (
	"github.com/gofiber/fiber/v2"
	"gorm.io/gorm"
	"guns-excel/internal/app/model"
)

// 增加模型
func AddModelExcel(ctx *fiber.Ctx, modelExcel *model.ModelExcel, db *gorm.DB) error {
	return db.Table("model_excel").Create(&modelExcel).Error
}

// 获取绑定模型数据
func GetModelExcelByModelId(ctx *fiber.Ctx, modelId string, db *gorm.DB) ([]*model.ModelExcel, error) {
	modelExcels := make([]*model.ModelExcel, 0)
	if err := db.Table("model_excel").Where("is_del = ?", 0).Where("model_id = ?", modelId).Find(&modelExcels).Error; err != nil {
		return nil, err
	}
	return modelExcels, nil
}
